import 'package:flutter/foundation.dart';
import 'package:get_storage/get_storage.dart';

class Auth with ChangeNotifier {
  String _token = GetStorage().read('token') ?? "";
  bool get isAuthenticated => _token.isNotEmpty;

  Future<void> login(String token) async {
    _token = token;
    GetStorage().write('token', token);
    notifyListeners();
  }

  Future<void> logout() async {
    _token = '';
    GetStorage().remove('token');
    notifyListeners();
  }

  Auth() {
    _token = _token;
  }
}
